Skip to content

feat(main): opt-in prompt logging#95

Open
antoine-gauvain wants to merge 1 commit into
DEVtheOPS:mainfrom
antoine-gauvain:main
Open

feat(main): opt-in prompt logging#95
antoine-gauvain wants to merge 1 commit into
DEVtheOPS:mainfrom
antoine-gauvain:main

Conversation

@antoine-gauvain

@antoine-gauvain antoine-gauvain commented Jul 3, 2026

Copy link
Copy Markdown

Description

Add the opt-in ability to log prompts.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Chore (dependency updates, etc.)

Checklist

  • I have read the CONTRIBUTING.md document
  • My code follows the style guidelines of this project
  • bun run lint passes with no errors
  • bun run check:jsdoc-coverage passes with no errors
  • bun run typecheck passes with no errors
  • bun test passes with no errors
  • I have added tests that prove my fix is effective or that my feature works (somewhat)
  • I have updated the documentation accordingly
  • My commits follow the Conventional Commits specification

Related issues

None related found

Additional context

N/A

Summary by CodeRabbit

  • New Features

    • Added an optional setting to include full prompt text in user_prompt telemetry events.
    • Documented a new environment variable to control this behavior.
  • Bug Fixes

    • user_prompt events now consistently include prompt details only when prompt capture is enabled.
    • Added clearer startup messaging when full prompt capture is active.
  • Tests

    • Expanded configuration tests to cover the new prompt-capture setting and its default behavior.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 182e4207-fb77-4023-aee9-f8c5cb602351

📥 Commits

Reviewing files that changed from the base of the PR and between a825320 and 09aeec1.

📒 Files selected for processing (4)
  • README.md
  • src/config.ts
  • src/index.ts
  • tests/config.test.ts

📝 Walkthrough

Walkthrough

Adds a new capturePrompt boolean field to PluginConfig, populated from the OPENCODE_CAPTURE_PROMPT environment variable. When enabled, the plugin logs a startup info message and conditionally includes full prompt text in user_prompt log events. Tests and README documentation are updated accordingly.

Changes

Prompt capture config and telemetry

Layer / File(s) Summary
Config field and loading logic
src/config.ts
PluginConfig adds a capturePrompt boolean field, and loadConfig() sets it based on hasNonEmptyEnv("OPENCODE_CAPTURE_PROMPT").
Prompt logging behavior
src/index.ts
Emits a startup info log when capturePrompt is enabled and conditionally adds a prompt attribute with full text to user_prompt log events.
Config tests and documentation
tests/config.test.ts, README.md
Tests verify default (false) and enabled (true via env var) behavior for capturePrompt; README documents the new env var and its effect on user_prompt log events.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dialupdisaster

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: an opt-in feature for logging prompts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@antoine-gauvain antoine-gauvain changed the title feat: opt-in prompt logging feat(main): opt-in prompt logging Jul 3, 2026
@antoine-gauvain antoine-gauvain marked this pull request as ready for review July 3, 2026 19:23
@dialupdisaster

Copy link
Copy Markdown
Contributor

Thanks for adding this. I think the feature is useful, but I want to clarify the behavior before we merge because prompts are already exported today in trace data.

Currently prompt text is attached to OTel spans via OpenInference attributes:

  • src/handlers/session.ts sets input.value and llm.input_messages on run/session spans
  • src/handlers/message.ts sets input.value and llm.input_messages on LLM spans

So this PR does not add prompt capture for the first time. It adds an opt-in copy of the prompt into the user_prompt OTLP log event.

That distinction matters for privacy/security expectations. With this change, OPENCODE_CAPTURE_PROMPT only controls whether prompts appear in logs. It does not prevent prompt text from being exported in traces when traces are enabled.

Could you update the README/startup wording to make that explicit? Something like:

OPENCODE_CAPTURE_PROMPT controls whether full prompt text is also included in user_prompt log events. Prompt text may already be exported as trace span attributes unless traces are disabled with OPENCODE_DISABLE_TRACES.

Also, repo convention is that config values are available both as OPENCODE_* env vars and plugin tuple options with option → env → default precedence. Could you add a matching capturePrompt?: boolean option to OtelPluginOptions, wire it through loadConfig, document it in the plugin options table, and add a small precedence test?

I’m supportive of the feature as log enrichment, but I’d like the naming/docs to avoid implying this is the only control for prompt export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants